package com.hwl.demo3.component;

import com.hwl.demo3.service.impl.CashSuper;

/**
 * @author sentry
 * @since 2023-02-28
 */
public class CashRebate extends CashSuper {

    private final double moneyRebate;

    /**
     * 打折收费，初始化时必须输入折扣率
     */
    public CashRebate(double moneyRebate) {
        this.moneyRebate = moneyRebate;
    }

    @Override
    public double acceptCash(double price, int num) {
        double result = price * num * this.moneyRebate;
        return super.acceptCash(result, 1);
    }
}
